home *** CD-ROM | disk | FTP | other *** search
/ Aminet 48 / Aminet 48 (2002)(GTI - Schatztruhe)[!][Apr 2002].iso / Aminet / util / moni / Scout-src.lha / netinclude / netinet / ip.h < prev    next >
Encoding:
C/C++ Source or Header  |  2002-02-13  |  4.0 KB  |  142 lines

  1. #ifndef NETINET_IP_H
  2. #define NETINET_IP_H \
  3.        "$Id: ip.h,v 1.1.1.1 2001/11/26 22:21:17 tboeckel Exp $"
  4. /*
  5.  *      Definitions for internet protocol version 4.
  6.  *      Per RFC 791, September 1981.
  7.  *
  8.  *      Copyright © 1994 AmiTCP/IP Group,
  9.  *                       Network Solutions Development, Inc.
  10.  *                       All rights reserved.
  11.  */
  12.  
  13. #define    IPVERSION    4
  14.  
  15. /*
  16.  * Structure of an internet header, naked of options.
  17.  *
  18.  * We declare ip_len and ip_off to be short, rather than u_short
  19.  * pragmatically since otherwise unsigned comparisons can result
  20.  * against negative integers quite easily, and fail in subtle ways.
  21.  */
  22. struct ip {
  23. #if BYTE_ORDER == LITTLE_ENDIAN 
  24.     u_char    ip_hl:4;        /* header length */
  25.     u_char    ip_v:4;            /* version */
  26. #endif
  27. #if BYTE_ORDER == BIG_ENDIAN 
  28.     u_char    ip_v:4;            /* version */
  29.     u_char    ip_hl:4;        /* header length */
  30. #endif
  31.     u_char    ip_tos;            /* type of service */
  32.     short    ip_len;            /* total length */
  33.     u_short    ip_id;            /* identification */
  34.     short    ip_off;            /* fragment offset field */
  35. #define    IP_DF 0x4000            /* dont fragment flag */
  36. #define    IP_MF 0x2000            /* more fragments flag */
  37.     u_char    ip_ttl;            /* time to live */
  38.     u_char    ip_p;            /* protocol */
  39.     u_short    ip_sum;            /* checksum */
  40.     struct    in_addr ip_src,ip_dst;    /* source and dest address */
  41. };
  42.  
  43. #define    IP_MAXPACKET    65535        /* maximum packet size */
  44.  
  45. /*
  46.  * Definitions for IP type of service (ip_tos)
  47.  */
  48. #define    IPTOS_LOWDELAY        0x10
  49. #define    IPTOS_THROUGHPUT    0x08
  50. #define    IPTOS_RELIABILITY    0x04
  51.  
  52. /*
  53.  * Definitions for IP precedence (also in ip_tos) (hopefully unused)
  54.  */
  55. #define    IPTOS_PREC_NETCONTROL        0xe0
  56. #define    IPTOS_PREC_INTERNETCONTROL    0xc0
  57. #define    IPTOS_PREC_CRITIC_ECP        0xa0
  58. #define    IPTOS_PREC_FLASHOVERRIDE    0x80
  59. #define    IPTOS_PREC_FLASH        0x60
  60. #define    IPTOS_PREC_IMMEDIATE        0x40
  61. #define    IPTOS_PREC_PRIORITY        0x20
  62. #define    IPTOS_PREC_ROUTINE        0x10
  63.  
  64. /*
  65.  * Definitions for options.
  66.  */
  67. #define    IPOPT_COPIED(o)        ((o)&0x80)
  68. #define    IPOPT_CLASS(o)        ((o)&0x60)
  69. #define    IPOPT_NUMBER(o)        ((o)&0x1f)
  70.  
  71. #define    IPOPT_CONTROL        0x00
  72. #define    IPOPT_RESERVED1        0x20
  73. #define    IPOPT_DEBMEAS        0x40
  74. #define    IPOPT_RESERVED2        0x60
  75.  
  76. #define    IPOPT_EOL        0        /* end of option list */
  77. #define    IPOPT_NOP        1        /* no operation */
  78.  
  79. #define    IPOPT_RR        7        /* record packet route */
  80. #define    IPOPT_TS        68        /* timestamp */
  81. #define    IPOPT_SECURITY        130        /* provide s,c,h,tcc */
  82. #define    IPOPT_LSRR        131        /* loose source route */
  83. #define    IPOPT_SATID        136        /* satnet id */
  84. #define    IPOPT_SSRR        137        /* strict source route */
  85.  
  86. /*
  87.  * Offsets to fields in options other than EOL and NOP.
  88.  */
  89. #define    IPOPT_OPTVAL        0        /* option ID */
  90. #define    IPOPT_OLEN        1        /* option length */
  91. #define IPOPT_OFFSET        2        /* offset within option */
  92. #define    IPOPT_MINOFF        4        /* min value of above */
  93.  
  94. /*
  95.  * Time stamp option structure.
  96.  */
  97. struct    ip_timestamp {
  98.     u_char    ipt_code;        /* IPOPT_TS */
  99.     u_char    ipt_len;        /* size of structure (variable) */
  100.     u_char    ipt_ptr;        /* index of current entry */
  101. #if BYTE_ORDER == LITTLE_ENDIAN 
  102.     u_char    ipt_flg:4;        /* flags, see below */
  103.     u_char    ipt_oflw:4;        /* overflow counter */
  104. #endif
  105. #if BYTE_ORDER == BIG_ENDIAN 
  106.     u_char    ipt_oflw:4;        /* overflow counter */
  107.     u_char    ipt_flg:4;        /* flags, see below */
  108. #endif
  109.     union ipt_timestamp {
  110.         n_long    ipt_time[1];
  111.         struct    ipt_ta {
  112.             struct in_addr ipt_addr;
  113.             n_long ipt_time;
  114.         } ipt_ta[1];
  115.     } ipt_timestamp;
  116. };
  117.  
  118. /* flag bits for ipt_flg */
  119. #define    IPOPT_TS_TSONLY        0        /* timestamps only */
  120. #define    IPOPT_TS_TSANDADDR    1        /* timestamps and addresses */
  121. #define    IPOPT_TS_PRESPEC    3        /* specified modules only */
  122.  
  123. /* bits for security (not byte swapped) */
  124. #define    IPOPT_SECUR_UNCLASS    0x0000
  125. #define    IPOPT_SECUR_CONFID    0xf135
  126. #define    IPOPT_SECUR_EFTO    0x789a
  127. #define    IPOPT_SECUR_MMMM    0xbc4d
  128. #define    IPOPT_SECUR_RESTR    0xaf13
  129. #define    IPOPT_SECUR_SECRET    0xd788
  130. #define    IPOPT_SECUR_TOPSECRET    0x6bc5
  131.  
  132. /*
  133.  * Internet implementation parameters.
  134.  */
  135. #define    MAXTTL        255        /* maximum time to live (seconds) */
  136. #define    IPFRAGTTL    60        /* time to live for frags, slowhz */
  137. #define    IPTTLDEC    1        /* subtracted when forwarding */
  138.  
  139. #define    IP_MSS        576        /* default maximum segment size */
  140.  
  141. #endif     /* NETINET_IP_H */
  142.